package com.android.vgongyi.service;

import org.json.JSONObject;

import tencent.activity.TencentDialog;
import tencent.api.User_API;
import tencent.beans.OAuth;
import android.app.Activity;

import com.android.vgongyi.common.AppApiPreference;
import com.android.vgongyi.entity.BlogPreferenceEntity;

public class BlogUserNicksApi {
	
	private Activity activity;
	
	public BlogUserNicksApi(Activity activity) {
		this.activity = activity;
	}
	
	public String getSinaUserNick(){
		return "";
	}
	
	public String getTencentUserNick() throws Exception{
		
		BlogPreferenceService service = new BlogPreferenceService(activity);
		User_API api = new User_API();
			
		//set app_key & key_secret
		OAuth oauth = new OAuth(TencentDialog.TENCENT_WEIBO_TAG); // 初始化OAuth请求令牌
		oauth.setOauth_consumer_key(AppApiPreference.TECENT_APP_KEY);
		oauth.setOauth_consumer_secret(AppApiPreference.TECENT_APP_KEY_SECRET);

		BlogPreferenceEntity entity = service.getTencentBlogPreference();
			
		oauth.setOauth_token(entity.getAccessToken());
		oauth.setOauth_token_secret(entity.getAccessTokenSecret());
			
		String str = api.info(oauth, "json");
		JSONObject obj = new JSONObject(str);
		JSONObject data  = obj.getJSONObject("data");

		String nick = data.getString("nick");
		
		return nick;
	}
	
	public String getSohuUserNick(){
		return "";
	}
	
	public String getWangyiUsreNick(){
		return "";
	}

}
